var PreiorSel="";
var isDel=false;
function SelectThis(ROWID)
{
	var theIndex;
	if (isDel)
	   PreiorSel="";
	isDel=false;
	if (PreiorSel!="")
	   parent.frames("AddFunction").document.all.item("Tb").rows(PreiorSel).className="Normal";
	ROWID.className="Selected";
	theIndex=parent.frames("FunctionList").document.all.item("FunctionList").selectedIndex;
	if (theIndex>=0)
  {
    parent.frames("FunctionList").document.all.item("FunctionList").options(theIndex).selected=false;
    parent.frames("SelBut").document.all.item("btnRight").disabled=1;
  }
 PreiorSel=ROWID.id;
 setData(ROWID.id);
}

function setData(RowIDSelected)
{
  parent.frames.item("SelBut").document.all.item("RowID").value=RowIDSelected;
  parent.frames.item("SelBut").document.all.item("btnLeft").disabled=0;
}


function RemoveFunction()
{
 var index,FunCode,FunName,Len
 index=AddFunForm.SelectedList.selectedIndex;
 if (index>=0)
 {
  FunCode=AddFunForm.SelectedList.options(index).value;
  FunName=AddFunForm.SelectedList.options(index).text;
  Len=parent.frames.item("FunctionList").FunctionList.length;
  parent.frames.item("FunctionList").FunctionList.length=Len+1;
  parent.frames.item("FunctionList").FunctionList.options(Len).text=FunName;
  parent.frames.item("FunctionList").FunctionList.options(Len).value=FunCode;
  AddFunForm.SelectedList.remove(index);
 }
}

function Init()
{
    if (parent.frames("AddFunction").window.document.all.tags("TABLE").length>0)
    {
        if (parent.frames("SelBut").window.document.all.tags("BUTTON").length>0)
	     parent.frames("SelBut").document.all.item("btnLeftAll").disabled=(Tb.rows.length>1?0:1);
   }
   if (parent.frames("Buttons").window.document.all.tags("BUTTON").length>0)
 		parent.frames("Buttons").EnabledBtns(1);
}

function thisClick()
{
 var RowID,Row;
 if (event.button==0 && (event.srcElement.tagName=="TD" || event.srcElement.tagName=="SELECT" ))
  {
   if (event.srcElement.tagName=="TD")
      Row=event.srcElement.parentElement;
  else
     Row=event.srcElement.parentElement.parentElement;
  if (Row.rowIndex>=1)
     SelectThis(Row);
  }
}

function thisClickdbl()
{
 if (event.button==0 && event.srcElement.tagName=="TD")
  {
    isDel=true;
    if (event.srcElement.parentElement.rowIndex>0)
    {
      setData(event.srcElement.parentElement.id);
      parent.frames.item("SelBut").DeleteThis();
    }
  }
}

